Part Number Hot Search : 
CNL325 42700 5110F3 R1E10 100CT 1KD10 950R30L GZ522
Product Description
Full Text Search
 

To Download PIC24FJ16GA004-EPT Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  ? 2008 microchip technology inc. ds39768d-page 1 pic24fjxxxga0xx 1.0 device overview this document defines the programming specification for the pic24fjxxxga0xx family of 16-bit micro- controller devices. this programming specification is required only for those developing programming support for the pic24fjxxxga0xx family. customers using only one of these devices should use development tools that already provide support for device programming. this specification includes programming specifications for the following devices: 2.0 programming overview of the pic24fjxxxga0xx family there are two methods of programming the pic24fjxxxga0xx family of devices discussed in this programming specification. they are: ? in-circuit serial programming? (icsp?) ? enhanced in-circuit serial programming (enhanced icsp) the icsp programming method is the most direct method to program the device; however, it is also the slower of the two methods. it provides native, low-level programming capability to erase, program and verify the chip. the enhanced in-circuit serial programming (enhanced icsp) protocol uses a faster method that takes advantage of the programming executive, as illustrated in figure 2-1. the programming executive provides all the necessary functionality to erase, pro- gram and verify the chip through a small command set. the command set allows the programmer to program the pic24fjxxxga0xx devices without having to deal with the low-level programming protocols of the chip. figure 2-1: programming system overview for enhanced icsp? this specification is divided into major sections that describe the programming methods independently. section 4.0 ?device programming ? enhanced icsp? describes the run-time self-programming (rtsp) method. section 3.0 ?device programming ? icsp? describes the in-circuit serial programming method. 2.1 power requirements all devices in the pic24fjxxxga0xx family are dual voltage supply designs: one supply for the core and peripherals and another for the i/o pins. a regulator is provided on-chip to alleviate the need for two external voltage supplies. all of the pic24fjxxxga0xx devices power their core digital logic at a nominal 2.5v. to simplify system design, all devices in the pic24fjxxxga0xx family incorporate an on-chip regulator that allows the device to run its core logic from v dd . ? pic24fj16ga002 ? pic24fj96ga006 ? pic24fj16ga004 ? pic24fj96ga008 ? pic24fj32ga002 ? pic24fj96ga010 ? pic24fj32ga004 ? pic24fj128ga006 ? pic24fj48ga002 ? pic24fj128ga008 ? pic24fj48ga004 ? pic24fj128ga010 ? pic24fj64ga002 ? pic24fj64ga004 ? pic24fj64ga006 ? pic24fj64ga008 ? pic24fj64ga010 pic24fjxxxga0xx programmer programming executive on-chip memory pic24fjxxxga0xx flash pr ogramming specification
pic24fjxxxga0xx ds39768d-page 2 ? 2008 microchip technology inc. the regulator provides power to the core from the other v dd pins. a low-esr capacitor (such as tantalum) must be connected to the v ddcore pin (figure 2-2 and figure 2-3). this helps to maintain the stability of the regulator. the specifications for core voltage and capac- itance are listed in section 7.0 ?ac/dc characteristics and timing requirements? . figure 2-2: connections for the on-chip regulator (64/80/100-pin devices) figure 2-3: conne ctions for the on-chip regulator (28/44-pin devices) v dd envreg v ddcore /v cap v ss pic24fjxxxga0xx c efc 3.3v regulator enabled (envreg tied to v dd ): (10 f typ) note 1: these are typical operating voltages. refer to section 7.0 ?ac/dc characteristics and timing requirements? for the full operating ranges of v dd and v ddcore . v dd envreg v ddcore /v cap v ss pic24fjxxxga0xx 3.3v (1) 2.5v (1) regulator disabled (envreg tied to ground): v dd envreg v ddcore /v cap v ss pic24fjxxxga0xx 2.5v (1) regulator disabled (v dd tied to v ddcore ): v dd disvreg v ddcore /v cap v ss pic24fjxxxga0xx 3.3v (1) 2.5v (1) regulator disabled (disvreg tied to v dd ): v dd disvreg v ddcore /v cap v ss pic24fjxxxga0xx 2.5v (1) regulator disabled (v dd tied to v ddcore ): v dd disvreg v ddcore /v cap v ss pic24fjxxxga0xx c efc 3.3v (10 f typ) regulator enabled (disvreg tied to v ss ): note 1: these are typical operating voltages. refer to section 7.0 ?ac/dc characteristics and timing requirements? for the full operating ranges of v dd and v ddcore .
? 2008 microchip technology inc. ds39768d-page 3 pic24fjxxxga0xx 2.2 program memory write/erase requirements the flash program memory on the pic24fjxxxga0xx devices has a specific write/erase requirement that must be adhered to for proper device operation. the rule is that any given word in memory must not be written more than twice before erasing the page in which it is located. thus, the easiest way to conform to this rule is to write all the data in a programming block within one write cycle. the programming methods specified in this specification comply with this requirement. 2.3 pin diagrams the pin diagrams for the pic24fjxxxga0xx family are shown in the following figures. the pins that are required for programming are listed in table 2-1 and are shown in bold letters in the figures. refer to the appropriate device data sheet for complete pin descriptions. table 2-1: pin descriptions (during programming) note: writing to a location multiple times without erasing is not recommended. pin name during programming pin name pin type pin description mclr mclr p programming enable envreg envreg i enable for on-chip voltage regulator disvreg (1) disvreg i disable for on-chip voltage regulator v dd and av dd (2) v dd p power supply v ss and av ss (2) v ss pground v ddcore v ddcore p regulated power supply for core pgc1 pgc i primary programming pin pair: serial clock pgd1 pgd i/o primary programming pin pair: serial data pgc2 pgc i secondary programming pin pair: serial clock pgd2 pgd i/o secondary programming pin pair: serial data legend: i = input, o = output, p = power note 1: applies to 28 and 44-pin devices only. 2: all power supply and ground pins must be connected, including analog supplies (av dd ) and ground (av ss ).
pic24fjxxxga0xx ds39768d-page 4 ? 2008 microchip technology inc. pin diagrams pic24fjxxga002 1 2 3 4 5 6 7 8 9 10 11 12 13 14 28 27 26 25 24 23 22 21 20 19 18 17 16 15 28-pin pdip, ssop, soic 28-pin qfn (1) 10 11 2 3 6 1 18 19 20 21 22 12 13 14 15 8 7 16 17 23 24 25 26 27 28 9 pic24fjxxga002 5 4 mclr v ss v dd ra0 ra1 pgd1 /emud1/an2/c2in-/ rp0 /cn4/rb0 ra4 rb4 ra3 ra2 rb3 rb2 pgc1 /emuc1/an3/c2in+/ rp1 /cn5/rb1 pgd3 /emud3/ rp5 /sda1/cn27/pmd7/rb5 v dd v ss pgc3 /emuc3/ rp6 /scl1/cn24/pmd6/rb6 disvreg v cap /v ddcore rb7 rb9 rb8 rb15 rb14 rb13 rb12 pgd2 /emud2/tdi/ rp10 /cn16/pmd2/rb10 pgc2 /emuc2/tms/ rp11 /cn15/pmd1/rb11 v ss pgd1 /emud1/an2/c2in-/ rp0 /cn4/rb0 ra3 ra2 rb3 rb2 pgc1 /emuc1/an3/c2in+/ rp1 /cn5/rb1 disvreg v cap /v ddcore rb9 rb13 rb12 pgd2 /emud2/tdi/ rp10 /cn16/pmd2/rb10 pgc2 /emuc2/tms/ rp11 /cn15/pmd1/rb11 v dd pgc3 /emuc3/ rp6 /scl1/cn24/pmd6/rb6 ra4 rb4 rb7 rb8 pgd3 /emud3/ rp5 /sda1/cn27/pmd7/rb5 mclr ra0 ra1 v dd vss rb15 rb14 legend: rpx represents remappable peripheral pins. note 1: the bottom pad of qfn packages should be connected to v ss .
? 2008 microchip technology inc. ds39768d-page 5 pic24fjxxxga0xx pin diagrams (continued) 10 11 2 3 4 5 6 1 18 19 20 21 22 12 13 14 15 38 8 7 44 43 42 41 40 39 16 17 29 30 31 32 33 23 24 25 26 27 28 36 34 35 9 pic24fjxxga004 37 44-pin qfn (1) rb8 rb7 pgc3 /emuc3/ rp6 /scl1/cn24/pmd6/rb6 pgd3 /emud3/ rp5 /sda1/cn27/pmd7/rb5 v dd ra9 ra4 v ss rc5 rc4 rc3 rb12 pgc2 /emuc2/ rp11 /cn15/pmd1/rb11 pgd2 /emud2/ rp10 /cn16/pmd2/rb10 v cap /v ddcore disvreg rc9 rc8 rc7 rc6 rb9 rb13 rb2 rb3 rc0 rc1 rc2 rb4 v dd v ss ra2 ra3 ra8 pgc1 /emuc1/an3/c2in+/ rp1 /cn5/rb1 pgd1 /emud1/an2/c2in-/ rp0 /cn4/rb0 ra1 ra0 mclr ra10 av dd av ss rb15 rb14 ra7 legend: rpx represents remappable peripheral pins. note 1: the bottom pad of qfn packages should be connected to v ss .
pic24fjxxxga0xx ds39768d-page 6 ? 2008 microchip technology inc. pin diagrams (continued) 10 11 2 3 4 5 6 1 18 19 20 21 22 12 13 14 15 38 8 7 44 43 42 41 40 39 16 17 29 30 31 32 33 23 24 25 26 27 28 36 34 35 9 37 44-pin tqfp pic24fjxxga004 rb12 pgc2 /emuc2/ rp11 /cn15/pmd1/rb11 pgd2 /emud2/ rp10 /cn16/pmd2/rb10 v cap /v ddcore disvreg rc9 rc8 rc7 rc6 rb9 rb13 rb2 rb3 rc0 rc1 rc2 rb4 v dd v ss ra2 ra3 ra8 rb8 rb7 pgc3 /emuc3/ rp6 /scl1/cn24/pmd6/rb6 pgd3 /emud3/ rp5 /sda1/cn27/pmd7/rb5 v dd ra9 ra4 v ss rc5 rc4 rc3 pgc1 /emuc1/an3/c2in+/ rp1 /cn5/rb1 pgd1 /emud1/an2/c2in-/ rp0 /cn4/rb0 ra1 ra0 mclr ra10 av dd av ss rb15 rb14 ra7 legend: rpx represents remappable peripheral pins.
? 2008 microchip technology inc. ds39768d-page 7 pic24fjxxxga0xx pin diagrams (continued) 64-pin tqfp 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 48 47 22 44 24 25 26 27 28 29 30 31 32 pic24fjxxga006 1 46 45 23 43 42 41 40 39 rd6 rd5 rd4 rd3 rd2 rd1 re4 re3 re2 re1 rf0 v cap /v ddcore rc13 rd0 rd10 rd9 rd8 rd11 rc15 rc12 v dd rg2 rf6 rf2 rf3 rg3 rc14 av dd rb8 rb9 rb10 rb11 v dd pgc2 /emuc2/an6/ocfa/rb6 pgd2 /emud2/an7/rb7 rf5 rf4 re5 re6 re7 rg6 v dd rb5 rb4 rb3 rb2 rg7 rg8 pgc1 /emuc1/v ref -/an1/cn3/rb1 pgd1 /emud1/pma6/v ref +/an0/cn2/rb0 rg9 mclr rb12 rb13 rb14 rb15 re0 rf1 rd7 v ss v ss vss envreg 63 62 61 59 60 58 57 56 54 55 53 52 51 49 50 38 37 34 36 35 33 17 19 20 21 18 av ss 64 pic24fjxxxga006
pic24fjxxxga0xx ds39768d-page 8 ? 2008 microchip technology inc. pin diagrams (continued) 80 79 78 20 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 60 59 26 56 40 39 28 29 30 31 32 33 34 35 36 37 38 pic24fjxxga008 17 18 19 1 76 77 58 57 27 55 54 53 52 51 rd5 rd4 rd13 rd12 rd3 rd2 rd1 re2 re1 re0 rg0 re4 re3 rf0 v cap /v ddcore rc13 rd0 rd10 rd9 rd8 rd11 ra15 ra14 rc15 rc12 v dd rg2 rf6 rf7 rf8 rg3 rf2 rf3 rc14 pma6/v ref +/ra10 pma7/v ref -/ra9 av dd rb8 rb9 pma13/cv ref /an10/rb10 rb11 v dd rd14 rd15 pgc2 /emuc2/an6/ocfa/rb6 pgd2 /emud2/an7/rb7 rf5 rf4 re5 re6 re7 rc1 rc3 rg6 v dd re8 re9 rb5 rb4 rb3 rb2 rg7 rg8 pgc1 /emuc1/an1/cn3/rb1 pgd1 /emud1/an0/cn2/rb0 rg9 mclr rb12 rb13 rb14 rb15 rg1 rf1 rd7 rd6 v ss v ss v ss envreg 75 74 73 71 72 70 69 68 66 67 65 64 63 61 62 50 49 46 48 47 45 44 43 42 41 21 23 24 25 22 av ss 80-pin tqfp pic24fjxxxga008
? 2008 microchip technology inc. ds39768d-page 9 pic24fjxxxga0xx pin diagrams (continued) 92 94 93 91 90 89 88 87 86 85 84 83 82 81 80 79 78 20 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 65 64 63 62 61 60 59 56 45 44 43 42 41 40 39 28 29 30 31 32 33 34 35 36 37 38 17 18 19 21 22 95 1 76 77 72 71 70 69 68 67 66 75 74 73 58 57 24 23 25 96 98 97 99 27 46 47 48 49 55 54 53 52 51 100 rd5 rd4 rd13 rd12 rd3 rd2 rd1 ra7 ra6 re2 rg13 rg12 rg14 re1 re0 rg0 re4 re3 rf0 rc13 rd0 rd10 rd9 rd8 rd11 rf2 ra14 rc15 rc12 v dd rg2 rf6 rf7 rf8 rg3 rf2 rf3 v ss rc14 ra10 pma7/v ref -/ra9 av dd av ss rb8 rb9 rb10 rb11 v dd rf12 rf13 rd14 rd15 v dd v ss pgc2 /emuc2/an6/ocfa/rb6 pgd2 /emud2/an7/rb7 rf5 rf4 re5 re6 re7 rc1 rc2 rc3 rc4 rg6 v dd ra0 re8 re9 rb5 rb4 rb3 rb2 rg7 rg8 pgc1 /emuc1/an1/cn3/rb1 pgd1 /emud1/an0/cn2/rb0 v dd rg15 prg9 mclr rb12 rb13 rb14 rb15 rg1 rf1 envreg rd6 tdo ra3 ra2 v ss v ss v ss v cap /v ddcore tdi ra1 100-pin tqfp 50 26 rd7 pic24fjxxga010 pic24fjxxxga010
pic24fjxxxga0xx ds39768d-page 10 ? 2008 microchip technology inc. 2.4 memory map the program memory map extends from 000000h to fffffeh. code storage is located at the base of the memory map and supports up to 44k instruction words (about 128 kbytes). table 2-3 shows the program memory size and number of erase and program blocks present in each device variant. each erase block, or page, contains 512 instructions, and each program block, or row, contains 64 instructions. locations 800000h through 8007feh are reserved for executive code memory. this region stores the programming executive and the debugging executive. the programming executive is used for device pro- gramming and the debugging executive is used for in-circuit debugging. this region of memory can not be used to store user code. the last two implemented program memory locations are reserved for the device configuration registers. table 2-2: flash configuration word locations for pic24fjxxxga0xx devices locations, ff0000h and ff0002h, are reserved for the device id registers. these bits can be used by the programmer to identify what device type is being programmed. they are described in section 6.1 ?device id? . the device id registers read out normally, even after code protection is applied. figure 2-4 shows the memory map for the pic24fjxxxga0xx family variants. table 2-3: code memory size device configuration word addresses 12 pic24fj16ga 002bfeh 002bfch pic24fj32ga 0057feh 0057fch pic24fj48ga 0083feh 0083fch pic24fj64ga 00abfeh 00abfch pic24fj96ga 00fffeh 00fffch pic24fj128gaga 0157feh 0157fch device user memory address limit (instruction words) write blocks erase blocks pic24fj16ga 002bfeh (5.5k) 88 11 pic24fj32ga 0057feh (11k) 176 22 pic24fj48ga 0083feh (16.5k) 264 33 pic24fj64ga 00abfeh (22k) 344 43 pic24fj96ga 00fffeh (32k) 512 64 pic24fj128ga 0157feh (44k) 688 86
? 2008 microchip technology inc. ds39768d-page 11 pic24fjxxxga0xx figure 2-4: program memory map user memory space 000000h configuration words code memory 015800h (1) 0157feh (1) configuration memory space (44031 x 24-bit) 800000h (2 x 24-bit) device id fefffeh ff0000h fffffeh reserved reserved 8007eeh 800800h executive code memory 7ffffeh ff0002h ff0004h reserved (2 x 16-bit) note 1: the address boundaries for user flash code memory are device dependent (see table 2-3). user flash (1024 x 24-bit) 0157fch (1) 0157fah (1) 8007f0h diagnostic and calibration words (8 x 24-bit)
pic24fjxxxga0xx ds39768d-page 12 ? 2008 microchip technology inc. 3.0 device programming ? icsp icsp mode is a special programming protocol that allows you to read and write to pic24fjxxxga0xx device family memory. the icsp mode is the most direct method used to program the device; note, how- ever, that enhanced icsp is faster. icsp mode also has the ability to read the contents of executive memory to determine if the programming executive is present. this capability is accomplished by applying control codes and instructions, serially to the device, using pins, pgcx and pgdx. in icsp mode, the system clock is taken from the pgcx pin, regardless of the device?s oscillator config- uration bits. all instructions are shifted serially into an internal buffer, then loaded into the instruction register (ir) and executed. no program fetching occurs from internal memory. instructions are fed in 24 bits at a time. pgdx is used to shift data in and pgcx is used as both the serial shift clock and the cpu execution clock. 3.1 overview of the programming process figure 3-1 shows the high-level overview of the programming process. after entering icsp mode, the first action is to chip erase the device. next, the code memory is programmed, followed by the device configuration registers. code memory (including the configuration registers) is then verified to ensure that programming was successful. then, program the code-protect configuration bits, if required. figure 3-1: high-level icsp? programming flow 3.2 icsp operation upon entry into icsp mode, the cpu is idle. execution of the cpu is governed by an internal state machine. a 4-bit control code is clocked in using pgcx and pgdx, and this control code is used to command the cpu (see table 3-1). the six control code is used to send instructions to the cpu for execution, and the regout control code is used to read data out of the device via the visi register. table 3-1: cpu control codes in icsp? mode note: during icsp operation, the operating frequency of pgcx must not exceed 10 mhz. 4-bit control code mnemonic description 0000b six shift in 24-bit instruction and execute. 0001b regout shift out the visi (0784h) register. 0010b-1111b n/a reserved. start perform chip erase program memory verify program done enter icsp? program configuration bits verify configuration bits exit icsp
? 2008 microchip technology inc. ds39768d-page 13 pic24fjxxxga0xx 3.2.1 six serial instruction execution the six control code allows execution of the pic24fjxxxga0xx family assembly instructions. when the six code is received, the cpu is suspended for 24 clock cycles, as the instruction is then clocked into the internal buffer. once the instruction is shifted in, the state machine allows it to be executed over the next four pgc clock cycles. while the received instruction is executed, the state machine simultaneously shifts in the next 4-bit command (see figure 3-2). coming out of reset, the first 4-bit control code is always forced to six and a forced nop instruction is executed by the cpu. five additional pgcx clocks are needed on start-up, resulting in a 9-bit six command instead of the normal 4-bit six command. after the forced six is clocked in, icsp operation resumes as normal. that is, the next 24 clock cycles load the first instruction word to the cpu. figure 3-2: six serial execution 3.2.1.1 differences between execution of six and normal instructions there are some differences between executing instruc- tions normally and using the six icsp command. as a result, the code examples in this specification may not match those for performing the same functions during normal device operation. the important differences are: ? two-word instructions require two six operations to clock in all the necessary data. examples of two-word instructions are goto and call . ? two-cycle instructions require two six operations. the first six operation shifts in the instruction and begins to execute it. a second six operation ? which should shift in a nop to avoid losing data ? provides the cpu clocks required to finish executing the instruction. examples of two-cycle instructions are table read and table write instructions. ? the cpu does not automatically stall to account for pipeline changes. a cpu stall occurs when an instruction modifies a register that is used for indirect addressing by the following instruction. during normal operation, the cpu automatically will force a nop while the new data is read. when using icsp, there is no automatic stall, so any indirect references to a recently modified register should be preceded by a nop . for example, the instructions, mov #0x0,w0 and mov [w0],w1 , must have a nop inserted between them. if a two-cycle instruction modifies a register that is used indirectly, it will require two following nop s: one to execute the second half of the instruction and a second to stall the cpu to correct the pipeline. instructions such as tblwtl [w0++],[w1] should be followed by two nop s. ? the device program counter (pc) continues to automatically increment during icsp instruction execution, even though the flash memory is not being used. as a result, the pc may be incremented to point to invalid memory locations. invalid memory spaces include unimplemented flash addresses and the vector space (locations 0x0 to 0x1ff). if the pc points to these locations, the device will reset, possibly interrupting the icsp operation. to prevent this, instructions should be periodically executed to reset the pc to a safe space. the optimal method to accomplish this is to perform a goto 0x200 . note: to account for this forced nop , all example code in this specification begin with a nop to ensure that no data is lost. p4 23 123 2324 1 2 3 4 p1 pgcx p4a pgdx 24-bit instruction fetch execute pc ? 1, 16 0000 fetch six 456 78 1819202122 17 lsb x x x x x x x x x x x x x x msb pgdx = input p2 p3 p1b p1a 78 9 0000 00 0 only for program memory entry control code 4 5 execute 24-bit instruction, fetch next control code 00
pic24fjxxxga0xx ds39768d-page 14 ? 2008 microchip technology inc. 3.2.2 regout serial instruction execution the regout control code allows for data to be extracted from the device in icsp mode. it is used to clock the contents of the visi register, out of the device, over the pgdx pin. after the regout control code is received, the cpu is held idle for 8 cycles. after these 8 cycles, an additional 16 cycles are required to clock the data out (see figure 3-3). the regout code is unique because the pgdx pin is an input when the control code is transmitted to the device. however, after the control code is processed, the pgdx pin becomes an output as the visi register is shifted out. figure 3-3: regout serial execution note 1: after the contents of visi are shifted out, the pic24fjxxxga0xx device maintains pgdx as an output until the first rising edge of the next clock is received. 2: data changes on the falling edge and latches on the rising edge of pgcx. for all data transmissions, the least significant bit (lsb) is transmitted first. 1234 1278 pgcx p4 pgdx pgdx = input execute previous instruction, cpu held in idle shift out visi register<15:0> p5 pgdx = output 123 1234 p4a 11 13 15 16 14 12 no execution takes place, fetch next control code 0 0000 pgdx = input msb 1234 1 45 6 lsb 14 13 12 ... 11 10 0 fetch regout control code 0
? 2008 microchip technology inc. ds39768d-page 15 pic24fjxxxga0xx 3.3 entering icsp mode as shown in figure 3-4, entering icsp program/verify mode requires three steps: 1. mclr is briefly driven high, then low. 2. a 32-bit key sequence is clocked into pgdx. 3. mclr is then driven high within a specified period of time and held. the programming voltage applied to mclr is v ih , which is essentially v dd in the case of pic24fjxxxga0xx devices. there is no minimum time requirement for holding at v ih . after v ih is removed, an interval of at least p18 must elapse before presenting the key sequence on pgdx. the key sequence is a specific 32-bit pattern: ? 0100 1101 0100 0011 0100 1000 0101 0001 ? (more easily remembered as 4d434851h in hexa- decimal). the device will enter program/verify mode only if the sequence is valid. the most significant bit (msb) of the most significant nibble must be shifted in first. once the key sequence is complete, v ih must be applied to mclr and held at that level for as long as program/verify mode is to be maintained. an interval of at least time, p19 and p7, must elapse before present- ing data on pgdx. signals appearing on pgcx before p7 has elapsed will not be interpreted as valid. on successful entry, the program memory can be accessed and programmed in serial fashion. while in icsp mode, all unused i/os are placed in the high-impedance state. figure 3-4: entering icsp? mode mclr pgdx pgcx v dd p6 p14 b31 b30 b29 b28 b27 b2 b1 b0 b3 ... program/verify entry code = 4d434851h p1a p1b p18 p19 0100 0 0 p7 v ih v ih 1 0 1
pic24fjxxxga0xx ds39768d-page 16 ? 2008 microchip technology inc. 3.4 flash memory programming in icsp mode 3.4.1 programming operations flash memory write and erase operations are controlled by the nvmcon register. programming is performed by setting nvmcon to select the type of erase operation (table 3-2) or write operation (table 3-3) and initiating the programming by setting the wr control bit (nvmcon<15>). in icsp mode, all programming operations are self-timed. there is an internal delay between the user setting the wr control bit and the automatic clearing of the wr control bit when the programming operation is complete. please refer to section 7.0 ?ac/dc characteristics and timing requirements? for information about the delays associated with various programming operations. table 3-2: nvmcon erase operations table 3-3: nvmcon write operations 3.4.2 starting and stopping a programming cycle the wr bit (nvmcon<15>) is used to start an erase or write cycle. setting the wr bit initiates the programming cycle. all erase and write cycles are self-timed. the wr bit should be polled to determine if the erase or write cycle has been completed. starting a programming cycle is performed as follows: 3.5 erasing program memory the procedure for erasing program memory (all of code memory, data memory, executive memory and code-protect bits) consists of setting nvmcon to 404fh and executing the programming cycle. a chip erase can erase all of user memory or all of both the user and configuration memory. a table write instruction should be executed prior to performing the chip erase to select which sections are erased. when this table write instruction is executed: ? if the tblpag register points to user space (is less than 0x80), the chip erase will erase only user memory. ? if tblpag points to configuration space (is greater than or equal to 0x80), the chip erase will erase both user and configuration memory. if configuration memory is erased, the internal oscillator calibration word, located at 0x807fe, will be erased. this location should be stored prior to performing a whole chip erase and restored afterward to prevent internal oscillators from becoming uncalibrated. figure 3-5 shows the icsp programming process for performing a chip erase. this process includes the icsp command code, which must be transmitted (for each instruction), least significant bit first, using the pgcx and pgdx pins (see figure 3-2). figure 3-5: chip erase flow nvmcon value erase operation 404fh erase all code memory, executive memory and configuration registers (does not erase unit id or device id registers). 4042h erase a page of code memory or executive memory. nvmcon value write operation 4003h write a configuration word register. 4001h program 1 row (64 instruction words) of code memory or executive memory. bset nvmcon, #wr note: program memory must be erased before writing any data to program memory. start done set the wr bit to initiate erase write 404fh to nvmcon sfr delay p11 + p10 time
? 2008 microchip technology inc. ds39768d-page 17 pic24fjxxxga0xx table 3-4: serial instruction execution for chip erase command (binary) data (hex) description step 1: exit the reset vector. 0000 0000 0000 000000 040200 000000 nop goto 0x200 nop step 2: set the nvmcon to erase all program memory. 0000 0000 2404fa 883b0a mov #0x404f, w10 mov w10, nvmcon step 3: set tblpag and perform dummy table write to select what portions of memory are erased. 0000 0000 0000 0000 0000 0000 200000 880190 200000 bb0800 000000 000000 mov #, w0 mov w0, tblpag mov #0x0000, w0 tblwtl w0,[w0] nop nop step 4: initiate the erase cycle. 0000 0000 0000 a8e761 000000 000000 bset nvmcon, #wr nop nop step 5: repeat this step to poll the wr bit (bit 15 of nvmcon) until it is cleared by the hardware. 0000 0000 0000 0000 0000 0001 0000 040200 000000 803b02 883c22 000000 000000 goto 0x200 nop mov nvmcon, w2 mov w2, visi nop clock out contents of the visi register. nop
pic24fjxxxga0xx ds39768d-page 18 ? 2008 microchip technology inc. 3.6 writing code memory the procedure for writing code memory is the same as the procedure for writing the configuration registers, except that 64 instruction words are programmed at a time. to facilitate this operation, working registers, w0:w5, are used as temporary holding registers for the data to be programmed. table 3-5 shows the icsp programming details, includ- ing the serial pattern with the icsp command code which must be transmitted, least significant bit first, using the pgcx and pgdx pins (see figure 3-2). in step 1, the reset vector is exited. in step 2, the nvmcon register is initialized for programming a full row of code memory. in step 3, the 24-bit starting des- tination address for programming is loaded into the tblpag register and w7 register. (the upper byte of the starting destination address is stored in tblpag and the lower 16 bits of the destination address are stored in w7.) to minimize the programming time, a packed instruction format is used (figure 3-6). in step 4, four packed instruction words are stored in working registers, w0:w5, using the mov instruction, and the read pointer, w6, is initialized. the contents of w0:w5 (holding the packed instruction word data) are shown in figure 3-6. in step 5, eight tblwt instructions are used to copy the data from w0:w5 to the write latches of code mem- ory. since code memory is programmed 64 instruction words at a time, steps 4 and 5 are repeated 16 times to load all the write latches (step 6). after the write latches are loaded, programming is initiated by writing to the nvmcon register in steps 7 and 8. in step 9, the internal pc is reset to 200h. this is a precautionary measure to prevent the pc from incrementing into unimplemented memory when large devices are being programmed. lastly, in step 10, steps 3-9 are repeated until all of code memory is programmed. figure 3-6: packed instruction words in w<0:5> 15 8 7 0 w0 lsw0 w1 msb1 msb0 w2 lsw1 w3 lsw2 w4 msb3 msb2 w5 lsw3 table 3-5: serial instruction execution for writing code memory command (binary) data (hex) description step 1: exit the reset vector. 0000 0000 0000 000000 040200 000000 nop goto 0x200 nop step 2: set the nvmcon to program 64 instruction words. 0000 0000 24001a 883b0a mov #0x4001, w10 mov w10, nvmcon step 3: initialize the write pointer (w7) for tblwt instruction. 0000 0000 0000 200xx0 880190 2xxxx7 mov #, w0 mov w0, tblpag mov #, w7 step 4: load w0:w5 with the next 4 instruction words to program. 0000 0000 0000 0000 0000 0000 2xxxx0 2xxxx1 2xxxx2 2xxxx3 2xxxx4 2xxxx5 mov #, w0 mov #, w1 mov #, w2 mov #, w3 mov #, w4 mov #, w5
? 2008 microchip technology inc. ds39768d-page 19 pic24fjxxxga0xx step 5: set the read pointer (w6) and load the (next set of) write latches. 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 eb0300 000000 bb0bb6 000000 000000 bbdbb6 000000 000000 bbebb6 000000 000000 bb1bb6 000000 000000 bb0bb6 000000 000000 bbdbb6 000000 000000 bbebb6 000000 000000 bb1bb6 000000 000000 clr w6 nop tblwtl [w6++], [w7] nop nop tblwth.b [w6++], [w7++] nop nop tblwth.b [w6++], [++w7] nop nop tblwtl [w6++], [w7++] nop nop tblwtl [w6++], [w7] nop nop tblwth.b [w6++], [w7++] nop nop tblwth.b [w6++], [++w7] nop nop tblwtl [w6++], [w7++] nop nop step 6: repeat steps 4 and 5, sixteen times, to load the write latches for 64 instructions. step 7: initiate the write cycle. 0000 0000 0000 a8e761 000000 000000 bset nvmcon, #wr nop nop step 8: repeat this step to poll the wr bit (bit 15 of nvmcon) until it is cleared by the hardware. 0000 0000 0000 0000 0000 0001 0000 040200 000000 803b02 883c22 000000 000000 goto 0x200 nop mov nvmcon, w2 mov w2, visi nop clock out contents of the visi register. nop step 9: reset device internal pc. 0000 0000 040200 000000 goto 0x200 nop step 10: repeat steps 3-9 until all code memory is programmed. table 3-5: serial instruction execution for writing code memory (continued) command (binary) data (hex) description
pic24fjxxxga0xx ds39768d-page 20 ? 2008 microchip technology inc. figure 3-7: program code memory flow start write sequence all locations done? no done start yes load 2 bytes to write buffer at all bytes written? no yes and poll for wr bit to be cleared n = 1 loopcount = 0 configure device for writes n = 1 loopcount = loopcount + 1 n = n + 1
? 2008 microchip technology inc. ds39768d-page 21 pic24fjxxxga0xx 3.7 writing configuration words the pic24fjxxxga0xx family configuration is stored in flash configuration words at the end of the user space program memory and in multiple register configuration words located in the test space. these registers reflect values read at any reset from program memory locations. the values can be changed only by programming the content of the corresponding flash configuration word and resetting the device. the reset forces an automatic reload of the flash stored configuration values by sequencing through the dedicated flash configuration words and transferring the data into the configuration registers. to change the values of the flash configuration word once it has been programmed, the device must be chip erased, as described in section 3.5 ?erasing program memory? , and reprogrammed to the desired value. it is not possible to program a ? 0 ? to ? 1 ?, but they may be programmed from a ? 1 ? to ? 0 ? to enable code protection. table 3-7 shows the icsp programming details for pro- gramming the configuration word locations, including the serial pattern with the icsp command code which must be transmitted, least significant bit first, using the pgcx and pgdx pins (see figure 3-2). in step 1, the reset vector is exited. in step 2, the nvmcon register is initialized for programming of code memory. in step 3, the 24-bit starting destination address for programming is loaded into the tblpag register and w7 register. the tblpag register must be loaded with the following: ? 96 and 64 kbyte devices ? 00h ? 128 kbyte devices ? 01h to verify the data by reading the configuration words after performing the write in order, the code protection bits initially should be programmed to a ? 1 ? to ensure that the verification can be performed properly. after verification is finished, the code protection bit can be programmed to a ? 0 ? by using a word write to the appropriate configuration word. table 3-6: default configuration register values address name default value last word cw1 7fffh (1) last word ? 2 cw2 ffffh note 1: cw1<15> is reserved and must be programmed to ? 0 ?.
pic24fjxxxga0xx ds39768d-page 22 ? 2008 microchip technology inc. table 3-7: serial instruction executio n for writing configuration registers command (binary) data (hex) description step 1: exit the reset vector. 0000 0000 0000 000000 040200 000000 nop goto 0x200 nop step 2: initialize the write pointer (w7) for the tblwt instruction. 0000 2xxxx7 mov , w7 step 3: set the nvmcon register to program cw2. 0000 0000 24003a 883b0a mov #0x4003, w10 mov w10, nvmcon step 4: initialize the tblpag register. 0000 0000 200xx0 880190 mov , w0 mov w0, tblpag step 5: load the configuration register data to w6. 0000 2xxxx6 mov #, w6 step 6: write the configuration register data to the write latch and increment the write pointer. 0000 0000 0000 0000 000000 bb1b86 000000 000000 nop tblwtl w6, [w7++] nop nop step 7: initiate the write cycle. 0000 0000 0000 a8e761 000000 000000 bset nvmcon, #wr nop nop step 8: repeat this step to poll the wr bit (bit 15 of nvmcon) until it is cleared by the hardware. 0000 0000 0000 0000 0000 0001 0000 040200 000000 803b02 883c22 000000 000000 goto 0x200 nop mov nvmcon, w2 mov w2, visi nop clock out contents of the visi register. nop step 9: reset device internal pc. 0000 0000 040200 000000 goto 0x200 nop step 10: repeat steps 5-9 to write cw1.
? 2008 microchip technology inc. ds39768d-page 23 pic24fjxxxga0xx 3.8 reading code memory reading from code memory is performed by executing a series of tblrd instructions and clocking out the data using the regout command. table 3-8 shows the icsp programming details for reading code memory. in step 1, the reset vector is exited. in step 2, the 24-bit starting source address for reading is loaded into the tblpag register and w6 register. the upper byte of the starting source address is stored in tblpag and the lower 16 bits of the source address are stored in w6. to minimize the reading time, the packed instruction word format that was utilized for writing is also used for reading (see figure 3-6). in step 3, the write pointer, w7, is initialized. in step 4, two instruction words are read from code memory and clocked out of the device, through the visi register, using the regout command. step 4 is repeated until the desired amount of code memory is read. table 3-8: serial instruction execution for reading code memory command (binary) data (hex) description step 1: exit reset vector. 0000 0000 0000 000000 040200 000000 nop goto 0x200 nop step 2: initialize tblpag and the read pointer (w6) for tblrd instruction. 0000 0000 0000 200xx0 880190 2xxxx6 mov #, w0 mov w0, tblpag mov #, w6 step 3: initialize the write pointer (w7) to point to the visi register. 0000 0000 207847 000000 mov #visi, w7 nop step 4: read and clock out the contents of the next two locations of code memory, through the visi register, using the regout command. 0000 0000 0000 0001 0000 0000 0000 0000 0000 0000 0000 0001 0000 0000 0000 0000 0001 0000 ba0b96 000000 000000 000000 badbb6 000000 000000 bad3d6 000000 000000 000000 ba0bb6 000000 000000 000000 tblrdl [w6], [w7] nop nop clock out contents of visi register nop tblrdh.b [w6++], [w7++] nop nop tblrdh.b [++w6], [w7--] nop nop clock out contents of visi register nop tblrdl [w6++], [w7] nop nop clock out contents of visi register nop step 5: reset device internal pc. 0000 0000 040200 000000 goto 0x200 nop step 6: repeat steps 4 and 5 until all desired code memory is read.
pic24fjxxxga0xx ds39768d-page 24 ? 2008 microchip technology inc. 3.9 reading configuration words the procedure for reading configuration memory is similar to the procedure for reading code memory, except that 16-bit data words are read (with the upper byte read being all ? 0 ?s) instead of 24-bit words. since there are two configuration registers, they are read one register at a time. table 3-9 shows the icsp programming details for reading the configuration words. note that the tblpag register must be loaded with 00h for 96 kbyte and below devices and 01h for 128 kbyte devices (the upper byte address of configuration memory), and the read pointer, w6, is initialized to the lower 16 bits of the configuration word location. table 3-9: serial instruction execution for reading all configuration memory command (binary) data (hex) description step 1: exit reset vector. 0000 0000 0000 000000 040200 000000 nop goto 0x200 nop step 2: initialize tblpag, the read pointer (w6) and the write pointer (w7) for tblrd instruction. 0000 0000 0000 0000 0000 200xx0 880190 2xxxx7 207847 000000 mov , w0 mov w0, tblpag mov , w6 mov #visi, w7 nop step 3: read the configuration register and write it to the visi register (located at 784h), and clock out the visi register using the regout command. 0000 0000 0000 0001 0000 ba0bb6 000000 000000 000000 tblrdl [w6++], [w7] nop nop clock out contents of visi register nop step 4: repeat step 3 again to read configuration word 1. step 5: reset device internal pc. 0000 0000 040200 000000 goto 0x200 nop
? 2008 microchip technology inc. ds39768d-page 25 pic24fjxxxga0xx 3.10 verify code memory and configuration word the verify step involves reading back the code memory space and comparing it against the copy held in the programmer?s buffer. the configuration registers are verified with the rest of the code. the verify process is shown in the flowchart in figure 3-8. memory reads occur a single byte at a time, so two bytes must be read to compare against the word in the programmer?s buffer. refer to section 3.8 ?reading code memory? for implementation details of reading code memory. figure 3-8: verify code memory flow 3.11 reading the application id word the application id word is stored at address 8005beh in executive code memory. to read this memory location, you must use the six control code to move this program memory location to the visi register. then, the regout control code must be used to clock the contents of the visi register out of the device. the corresponding control and instruction codes that must be serially transmitted to the device to perform this operation are shown in table 3-10. after the programmer has clocked out the application id word, it must be inspected. if the application id has the value, bbh, the programming executive is resident in memory and the device can be programmed using the mechanism described in section 4.0 ?device programming ? enhanced icsp? . however, if the application id has any other value, the programming executive is not resident in memory; it must be loaded to memory before the device can be programmed. the procedure for loading the programming executive to memory is described in section 5.4 ?programming the programming executive to memory? . 3.12 exiting icsp mode exiting program/verify mode is done by removing v ih from mclr , as shown in figure 3-9. the only require- ment for exit is that an interval, p16, should elapse between the last clock and program signals on pgcx and pgdx before removing v ih . figure 3-9: exiting icsp? mode note: because the configuration registers include the device code protection bit, code memory should be verified immedi- ately after writing if code protection is enabled. this is because the device will not be readable or verifiable if a device reset occurs after the code-protect bit in cw1 has been cleared. read low byte read high byte does word = expect data? failure, report error all code memory verified? no yes no set tblptr = 0 start yes done with post-increment with post-increment mclr p16 pgdx pgd = input pgcx v dd v ih v ih p17
pic24fjxxxga0xx ds39768d-page 26 ? 2008 microchip technology inc. table 3-10: serial instruction execution for reading the application id word command (binary) data (hex) description step 1: exit reset vector. 0000 0000 0000 000000 040200 000000 nop goto 0x200 nop step 2: initialize tblpag and the read pointer (w0) for tblrd instruction. 0000 0000 0000 0000 0000 0000 0000 0000 200800 880190 205be0 207841 000000 ba0890 000000 000000 mov #0x80, w0 mov w0, tblpag mov #0x5be, w0 mov #visi, w1 nop tblrdl [w0], [w1] nop nop step 3: output the visi register using the regout command. 0001 0000 000000 clock out contents of the visi register nop
? 2008 microchip technology inc. ds39768d-page 27 pic24fjxxxga0xx 4.0 device programming ? enhanced icsp this section discusses programming the device through enhanced icsp and the programming execu- tive. the programming executive resides in executive memory (separate from code memory) and is executed when enhanced icsp programming mode is entered. the programming executive provides the mechanism for the programmer (host device) to program and verify the pic24fjxxxga0xx devices using a simple command set and communication protocol. there are several basic functions provided by the programming executive: ? read memory ? erase memory ? program memory ? blank check ? read executive firmware revision the programming executive performs the low-level tasks required for erasing, programming and verifying a device. this allows the programmer to program the device by issuing the appropriate commands and data. table 4-1 summarizes the commands. a detailed description for each command is provided in section 5.2 ?programming executive commands? . table 4-1: command set summary the programming executive uses the device?s data ram for variable storage and program execution. after the programming executive has run, no assumptions should be made about the contents of data ram. 4.1 overview of the programming process figure 4-1 shows the high-level overview of the programming process. after entering enhanced icsp mode, the programming executive is verified. next, the device is erased. then, the code memory is programmed, followed by the configuration locations. code memory (including the configuration registers) is then verified to ensure that programming was successful. after the programming executive has been verified in memory (or loaded if not present), the pic24fjxxxga0xx family can be programmed using the command set shown in table 4-1. figure 4-1: high-level enhanced icsp? programming flow 4.2 confirming the presence of the programming executive before programming can begin, the programmer must confirm that the programming executive is stored in executive memory. the procedure for this task is shown in figure 4-2. first, in-circuit serial programming mode (icsp) is entered. then, the unique application id word stored in executive memory is read. if the programming executive is resident, the application id word is bbh, which means programming can resume as normal. however, if the application id word is not bbh, the programming executive must be programmed to executive code memory using the method described in section 5.4 ?programming the programming executive to memory? . section 3.0 ?device programming ? icsp? describes the icsp programming method. section 3.11 ?reading the application id word? describes the procedure for reading the application id word in icsp mode. command description scheck sanity check readc read device id registers readp read code memory progp program one row of code memory and verify progw program one word of code memory and verify qblank query if the code memory is blank qver query the software version start done perform chip erase program memory verify program enter enhanced icsp? program configuration bits verify configuration bits exit enhanced icsp
pic24fjxxxga0xx ds39768d-page 28 ? 2008 microchip technology inc. figure 4-2: confir ming presence of programming executive 4.3 entering enhanced icsp mode as shown in figure 4-3, entering enhanced icsp program/verify mode requires three steps: 1. the mclr pin is briefly driven high, then low. 2. a 32-bit key sequence is clocked into pgdx. 3. mclr is then driven high within a specified period of time and held. the programming voltage applied to mclr is v ih , which is essentially v dd in the case of pic24fjxxxga0xx devices. there is no minimum time requirement for holding at v ih . after v ih is removed, an interval of at least p18 must elapse before presenting the key sequence on pgdx. the key sequence is a specific 32-bit pattern: ? 0100 1101 0100 0011 0100 1000 0101 0000 ? (more easily remembered as 4d434850h in hexa- decimal format). the device will enter program/verify mode only if the key sequence is valid. the most significant bit (msb) of the most significant nibble must be shifted in first. once the key sequence is complete, v ih must be applied to mclr and held at that level for as long as program/verify mode is to be maintained. an interval of at least time p19 and p7 must elapse before presenting data on pgdx. signals appearing on pgdx before p7 has elapsed will not be interpreted as valid. on successful entry, the program memory can be accessed and programmed in serial fashion. while in the program/verify mode, all unused i/os are placed in the high-impedance state. figure 4-3: entering enhanced icsp? mode is start enter icsp? mode application id bbh? resident in memory yes no prog. executive is application id read the be programmed prog. executive must from address 807f0h finish mclr pgdx pgcx v dd p6 p14 b31 b30 b29 b28 b27 b2 b1 b0 b3 ... program/verify entry code = 4d434850h p1a p1b p18 p19 01001 0000 p7 v ih v ih
? 2008 microchip technology inc. ds39768d-page 29 pic24fjxxxga0xx 4.4 blank check the term ?blank check? implies verifying that the device has been successfully erased and has no programmed memory locations. a blank or erased memory location is always read as ? 1 ?. the device id registers (ff0002h:ff0000h) can be ignored by the blank check since this region stores device information that cannot be erased. the device configuration registers are also ignored by the blank check. additionally, all unimplemented memory space should be ignored by the blank check. the qblank command is used for the blank check. it determines if the code memory is erased by testing these memory regions. a ?blank? or ?not blank? response is returned. if it is determined that the device is not blank, it must be erased before attempting to program the chip. 4.5 code memory programming 4.5.1 programming methodology code memory is programmed with the progp command. progp programs one row of code memory starting from the memory address specified in the command. the number of progp commands required to program a device depends on the number of write blocks that must be programmed in the device. a flowchart for programming code memory is shown in figure 4-4. in this example, all 44k instruction words of a pic24fj128ga device are programmed. first, the number of commands to send (called ?remainingcmds? in the flowchart) is set to 688 and the destination address (called ?baseaddress?) is set to ? 0 ?. next, one write block in the device is programmed with a progp command. each progp command contains data for one row of code memory of the pic24fjxxxga0xx device. after the first command is processed successfully, ?remainingcmds? is decre- mented by 1 and compared with 0. since there are more progp commands to send, ?baseaddress? is incremented by 80h to point to the next row of memory. on the second progp command, the second row is programmed. this process is repeated until the entire device is programmed. no special handling must be performed when a panel boundary is crossed. figure 4-4: flowchart for programming code memory is progp response pass? are remainingcmds ? 0 ?? baseaddress = 00h remainingcmds = 688 remainingcmds = remainingcmds ? 1 baseaddress = baseaddress + 80h no no yes yes start failure report error send progp command to program baseaddress finish
pic24fjxxxga0xx ds39768d-page 30 ? 2008 microchip technology inc. 4.5.2 programming verification after code memory is programmed, the contents of memory can be verified to ensure that programming was successful. verification requires code memory to be read back and compared against the copy held in the programmer?s buffer. the readp command can be used to read back all of the programmed code memory. alternatively, you can have the programmer perform the verification after the entire device is programmed using a checksum computation. 4.6 configuration bits programming 4.6.1 overview the pic24fjxxxga0xx family has configuration bits stored in the last two locations of implemented program memory (see table 2-2 for locations). these bits can be set or cleared to select various device configura- tions. there are three types of configuration bits: system operation bits, code-protect bits and unit id bits. the system operation bits determine the power-on settings for system level components, such as oscillator and watchdog timer. the code-protect bits prevent program memory from being read and written. the register descriptions for the cw1 and cw2 configuration registers are shown in table 4-2. table 4-2: pic24fjxxxga0xx family configuration bi ts description bit field register description i2c1sel (1) cw2<2> i2c1 pin mapping bit 1 = default location for scl1/sda1 pins 0 = alternate location for scl1/sda1 pins debug cw1<11> background debug enable bit 1 = device will reset in user mode 0 = device will reset in debug mode fcksm1:fcksm0 cw2<7:6> clock switching mode bits 1x = clock switching is disabled, fail-safe clock monitor is disabled 01 = clock switching is enabled, fail-safe clock monitor is disabled 00 = clock switching is enabled, fail-safe clock monitor is enabled fnosc2:fnosc0 cw2<10:8> initial oscillator source selection bits 111 = internal fast rc (frcdiv) oscillator with postscaler 110 = reserved 101 = low-power rc (lprc) oscillator 100 = secondary (sosc) oscillator 011 = primary (xtpll, hspll, ecpll) oscillator with pll 010 = primary (xt, hs, ec) oscillator 001 = internal fast rc (frcpll) oscillator with postscaler and pll 000 = fast rc (frc) oscillator fwdten cw1<7> watchdog timer enable bit 1 = watchdog timer always enabled (lprc oscillator cannot be disabled; clearing the swdten bit in the rcon register will have no effect) 0 = watchdog timer enabled/disabled by user software (lprc can be disabled by clearing the swdten bit in the rcon register) gcp cw1<13> general segment code-protect bit 1 = user program memory is not code-protected 0 = user program memory is code-protected gwrp cw1<12> general segment write-protect bit 1 = user program memory is not write-protected 0 = user program memory is write-protected ics cw1<8> icd communication channel select bit 1 = communicate on pgc2/emuc2 and pgd2/emud2 0 = communicate on pgc1/emuc1 and pgd1/emud1 note 1: available on 28 and 44-pin packages only. 2: available only on 28 and 44-pin devices with a silicon revision of 3042h or higher.
? 2008 microchip technology inc. ds39768d-page 31 pic24fjxxxga0xx ics (1) cw1<8> icd pin placement select bit 11 = icd emuc/emud pins are shared with pgc1/pgd1 10 = icd emuc/emud pins are shared with pgc2/pgd2 01 = icd emuc/emud pins are shared with pgc3/pgd3 00 = reserved; do not use ieso cw2<15> internal external switchover bit 1 = two-speed start-up enabled 0 = two-speed start-up disabled iol1way (1) cw2<4> iolock bit one-way set enable bit 0 = the osccon bit can be set and cleared as needed (provided an unlocking sequence is executed) 1 = the osccon bit can only be set once (provided an unlocking sequence is executed). once iolock is set, this prevents any possible future rp register changes jtagen cw1<14> jtag enable bit 1 = jtag enabled 0 = jtag disabled osciofnc cw2<5> osc2 pin function bit (except in xt and hs modes) 1 = osc2 is clock output 0 = osc2 is general purpose digital i/o pin soscsel1: soscsel0 (2) cw2<12:11> secondary oscillator power mode select bits 11 = default (high drive strength) mode 01 = low-power (low drive strength) mode x0 = reserved; do not use poscmd1: poscmd0 cw2<1:0> primary oscillator mode select bits 11 = primary oscillator disabled 10 = hs crystal oscillator mode 01 = xt crystal oscillator mode 00 = ec (external clock) mode wdtpost3: wdtpost0 cw1<3:0> watchdog timer prescaler bit 1111 = 1:32,768 1110 = 1:16,384 . . . 0001 = 1:2 0000 = 1:1 wdtpre cw1<4> watchdog timer postscaler bit 1 = 1:128 0 = 1:32 windis cw1<6> windowed wdt bit 1 = watchdog timer in non-window mode 0 = watchdog timer in window mode; fwdten must be ? 1 ? wutsel1: wutsel0 (2) cw2<14:13> voltage regulator standby mode wake-up time select bits 11 = default regulator wake time used 01 = fast regulator wake time used x0 = reserved; do not use table 4-2: pic24fjxxxga0xx family conf iguration bits description (continued) bit field register description note 1: available on 28 and 44-pin packages only. 2: available only on 28 and 44-pin devices with a silicon revision of 3042h or higher.
pic24fjxxxga0xx ds39768d-page 32 ? 2008 microchip technology inc. 4.6.2 programming methodology configuration bits may be programmed a single byte at a time using the progw command. this command specifies the configuration data and configuration register address. when configuration bits are programmed, any unimplemented or reserved bits must be programmed with a ? 1 ?. two progw commands are required to program the configuration bits. a flowchart for configuration bit programming is shown in figure 4-5. 4.6.3 programming verification after the configuration bits are programmed, the contents of memory should be verified to ensure that the programming was successful. verification requires the configuration bits to be read back and compared against the copy held in the programmer?s buffer. the readp command reads back the programmed configuration bits and verifies that the programming was successful. 4.6.4 code-protect configuration bits cw1 configuration register controls code protection for the pic24fjxxxga0xx family. two forms of code pro- tection are provided. one form prevents code memory from being written (write protection) and the other prevents code memory from being read (read protection). gwrp (cw1<12>) controls write protection and gcp (cw1<13>) controls read protection. protection is enabled when the respective bit is ? 0 ?. erasing sets gwrp and gcp to ? 1 ?, which allows the device to be programmed. when write protection is enabled (gwrp = 0 ), any programming operation to code memory will fail. when read protection is enabled (gcp = 0 ), any read from code memory will cause a 0h to be read, regard- less of the actual contents of code memory. since the programming executive always verifies what it programs, attempting to program code memory with read protection enabled also will result in failure. it is imperative that both gwrp and gcp are ? 1 ? while the device is being programmed and verified. only after the device is programmed and verified should either gwrp or gcp be programmed to ? 0 ? (see section 4.6 ?configuration bits programming? ). note: if the general segment code-protect bit (gcp) is programmed to ? 0 ?, code memory is code-protected and can not be read. code memory must be verified before enabling read protection. see section 4.6.4 ?code-protect configuration bits? for more information about code-protect configuration bits. note: bulk erasing in icsp mode is the only way to reprogram code-protect bits from an on state (? 0 ?) to an off state (? 1 ?).
? 2008 microchip technology inc. ds39768d-page 33 pic24fjxxxga0xx figure 4-5: conf iguration bit pr ogramming flow 4.7 exiting enhanced icsp mode exiting program/verify mode is done by removing v ih from mclr , as shown in figure 4-6. the only require- ment for exit is that an interval, p16, should elapse between the last clock and program signals on pgcx and pgdx before removing v ih . figure 4-6: exiting enhanced icsp? mode send progw command configaddress = 0157fch (1) is progw response pass? no yes no failure report error start finish yes is configaddress 0157feh? (1) configaddress = configaddress + 2 note 1: configuration word addresses for pic24fj128ga devic es are shown. refer to table 2-2 for others. mclr p16 pgdx pgdx = input pgcx v dd v ih v ih p17
pic24fjxxxga0xx ds39768d-page 34 ? 2008 microchip technology inc. 5.0 the programming executive 5.1 programming executive communication the programmer and programming executive have a master-slave relationship, where the programmer is the master programming device and the programming executive is the slave. all communication is initiated by the programmer in the form of a command. only one command at a time can be sent to the programming executive. in turn, the programming executive only sends one response to the programmer after receiving and processing a command. the programming executive command set is described in section 5.2 ?programming executive commands? . the response set is described in section 5.3 ?programming executive responses? . 5.1.1 communication interface and protocol the enhanced icsp interface is a 2-wire spi, implemented using the pgcx and pgdx pins. the pgcx pin is used as a clock input pin and the clock source must be provided by the programmer. the pgdx pin is used for sending command data to, and receiving response data from, the programming executive. data transmits to the device must change on the rising edge and hold on the falling edge. data receives from the device must change on the falling edge and hold on the rising edge. all data transmissions are sent to the most significant bit (msb) first, using 16-bit mode (see figure 5-1). figure 5-1: programming executive serial timing for data received from device figure 5-2: programming executive serial timing for data transmitted to device since a 2-wire spi is used, and data transmissions are half duplex, a simple protocol is used to control the direction of pgdx. when the programmer completes a command transmission, it releases the pgdx line and allows the programming executive to drive this line high. the programming executive keeps the pgdx line high to indicate that it is processing the command. after the programming executive has processed the command, it brings pgdx low for 15 sec to indicate to the programmer that the response is available to be clocked out. the programmer can begin to clock out the response 23 sec after pgdx is brought low, and it must provide the necessary amount of clock pulses to receive the entire response from the programming executive. after the entire response is clocked out, the program- mer should terminate the clock on pgcx until it is time to send another command to the programming executive. this protocol is shown in figure 5-3. 5.1.2 spi rate in enhanced icsp mode, the pic24fjxxxga0xx family devices operate from the internal fast rc oscil- lator (frcdiv), which has a nominal frequency of 8 mhz. this oscillator frequency yields an effective system clock frequency of 4 mhz. to ensure that the programmer does not clock too fast, it is recommended that a 4 mhz clock be provided by the programmer. 5.1.3 time-outs the programming executive uses no watchdog timer or time-out for transmitting responses to the program- mer. if the programmer does not follow the flow control mechanism using pgcx, as described in section 5.1.1 ?communication interface and protocol? , it is possible that the programming executive will behave unexpectedly while trying to send a response to the programmer. since the programming executive has no time-out, it is imperative that the programmer correctly follow the described communication protocol. as a safety measure, the programmer should use the command time-outs identified in table 5-1. if the command time-out expires, the programmer should reset the programming executive and start programming the device again. pgcx pgdx 123 11 13 15 16 14 12 lsb 14 13 12 11 45 6 msb 1 2 3 ... 4 5 p2 p3 p1 p1b p1a pgcx pgdx 123 11 13 15 16 14 12 lsb 14 13 12 11 45 6 msb 1 2 3 ... 4 5 p2 p3 p1 p1b p1a
? 2008 microchip technology inc. ds39768d-page 35 pic24fjxxxga0xx figure 5-3: programming executive ? programmer communication protocol 5.2 programming executive commands the programming executive command set is shown in table 5-1. this table contains the opcode, mnemonic, length, time-out and description for each command. functional details on each command are provided in section 5.2.4 ?command descriptions? . 5.2.1 command format all programming executive commands have a general format consisting of a 16-bit header and any required data for the command (see figure 5-4). the 16-bit header consists of a 4-bit opcode field, which is used to identify the command, followed by a 12-bit command length field. figure 5-4: command format the command opcode must match one of those in the command set. any command that is received which does not match the list in table 5-1 will return a ?nack? response (see section 5.3.1.1 ?opcode field? ). the command length is represented in 16-bit words since the spi operates in 16-bit mode. the program- ming executive uses the command length field to determine the number of words to read from the spi port. if the value of this field is incorrect, the command will not be properly received by the programming executive. 5.2.2 packed data format when 24-bit instruction words are transferred across the 16-bit spi interface, they are packed to conserve space using the format shown in figure 5-5. this format minimizes traffic over the spi and provides the programming executive with data that is properly aligned for performing table write operations. figure 5-5: packed instruction word format 5.2.3 programming executive error handling the programming executive will ?nack? all unsupported commands. additionally, due to the memory constraints of the programming executive, no checking is performed on the data contained in the programmer command. it is the responsibility of the programmer to command the programming executive with valid command arguments or the programming operation may fail. additional information on error handling is provided in section 5.3.1.3 ?qe_code field? . 1 2 15 16 1 2 15 16 pgcx pgdx pgcx = input pgcx = input (idle) host transmits last command word pgdx = input pgdx = output p8 12 1516 msb x x x lsb msb x x x lsb msb x x x lsb 1 0 p20 pgcx = input pgdx = output p9 programming executive processes command host clocks out response p21 15 12 11 0 opcode length command data first word (if required) ? ? command data last word (if required) note: when the number of instruction words transferred is odd, msb2 is zero and lsw2 can not be transmitted. 15 8 7 0 lsw1 msb2 msb1 lsw2 lswx: least significant 16 bits of instruction word msbx: most significant bytes of instruction word
pic24fjxxxga0xx ds39768d-page 36 ? 2008 microchip technology inc. table 5-1: programming executive command set 5.2.4 command descriptions all commands supported by the programming executive are described in section 5.2.5 ?scheck command? through section 5.2.12 ?qver command? . 5.2.5 scheck command the scheck command instructs the programming executive to do nothing but generate a response. this command is used as a ?sanity check? to verify that the programming executive is operational. expected response (2 words): 1000h 0002h opcode mnemonic length (16-bit words) time-out description 0h scheck 1 1 ms sanity check. 1h readc 3 1 ms read an 8-bit word from the specified device id register. 2h readp 4 1 ms/row read n 24-bit instruction words of code memory starting from the specified address. 3h reserved n/a n/a this command is reserved. it will return a nack. 4h progc 4 5 ms write an 8-bit word to the specified device id registers. 5h progp 99 5 ms program one row of code memory at the specified address, then verify. (1) 7h reserved n/a n/a this command is reserved. it will return a nack. 8h reserved n/a n/a this command is reserved. it will return a nack. 9h reserved n/a n/a this command is reserved. it will return a nack. ah qblank 3 tbd query if the code memory is blank. bh qver 1 1 ms query the programming executive software version. dh progw 4 5 ms program one instruction word of code memory at the specified address, then verify. legend: tbd = to be determined note 1: one row of code memory consists of (64) 24-bit word s. refer to table 2-3 for device-specific information. 15 12 11 0 opcode length field description opcode 0h length 1h note: this instruction is not required for programming but is provided for development purposes only.
? 2008 microchip technology inc. ds39768d-page 37 pic24fjxxxga0xx 5.2.6 readc command the readc command instructs the programming executive to read n or device id registers, starting from the 24-bit address specified by addr_msb and addr_ls. this command can only be used to read 8-bit or 16-bit data. when this command is used to read device id registers, the upper byte in every data word returned by the programming executive is 00h and the lower byte contains the device id register value. expected response (4 + 3 * (n ? 1)/2 words for n odd): 1100h 2 + n device id register 1 ... device id register n 5.2.7 readp command the readp command instructs the programming executive to read n 24-bit words of code memory, including configuration words, starting from the 24-bit address specified by addr_msb and addr_ls. this command can only be used to read 24-bit data. all data returned in response to this command uses the packed data format described in section 5.2.2 ?packed data format? . expected response (2 + 3 * n/2 words for n even): 1200h 2 + 3 * n/2 least significant program memory word 1 ... least significant data word n expected response (4 + 3 * (n ? 1)/2 words for n odd): 1200h 4 + 3 * (n ? 1)/2 least significant program memory word 1 ... msb of program memory word n (zero padded) 15 12 11 8 7 0 opcode length naddr_msb addr_ls field description opcode 1h length 3h n number of 8-bit device id registers to read (max. of 256) addr_msb msb of 24-bit source address addr_ls least significant 16 bits of 24-bit source address note: reading unimplemented memory will cause the programming executive to reset. please ensure that only memory locations present on a particular device are accessed. 15 12 11 8 7 0 opcode length n reserved addr_msb addr_ls field description opcode 2h length 4h n number of 24-bit instructions to read (max. of 32768) reserved 0h addr_msb msb of 24-bit source address addr_ls least significant 16 bits of 24-bit source address note: reading unimplemented memory will cause the programming executive to reset. please ensure that only memory locations present on a particular device are accessed.
pic24fjxxxga0xx ds39768d-page 38 ? 2008 microchip technology inc. 5.2.8 progc command the progc command instructs the programming executive to program a single device id register located at the specified memory address. after the specified data word has been programmed to code memory, the programming executive verifies the programmed data against the data in the command. expected response (2 words): 1400h 0002h 5.2.9 progp command the progp command instructs the programming executive to program one row of code memory, includ- ing configuration words (64 instruction words), to the specified memory address. programming begins with the row address specified in the command. the destination address should be a multiple of 80h. the data to program to memory, located in command words, d_1 through d_96, must be arranged using the packed instruction word format shown in figure 5-5. after all data has been programmed to code memory, the programming executive verifies the programmed data against the data in the command. expected response (2 words): 1500h 0002h 15 12 11 8 7 0 opcode length reserved addr_msb addr_ls data field description opcode 4h length 4h reserved 0h addr_msb msb of 24-bit destination address addr_ls least significant 16 bits of 24-bit destination address data 8-bit data word 15 12 11 8 7 0 opcode length reserved addr_msb addr_ls d_1 d_2 ... d_96 field description opcode 5h length 63h reserved 0h addr_msb msb of 24-bit destination address addr_ls least significant 16 bits of 24-bit destination address d_1 16-bit data word 1 d_2 16-bit data word 2 ... 16-bit data word 3 through 95 d_96 16-bit data word 96 note: refer to table 2-3 for code memory size information.
? 2008 microchip technology inc. ds39768d-page 39 pic24fjxxxga0xx 5.2.10 progw command the progw command instructs the programming executive to program one word of code memory (3 bytes) to the specific memory address. after the word has been programmed to code memory, the programming executive verifies the programmed data against the data in the command. expected response (2 words): 1600h 0002h 5.2.11 qblank command the qblank command queries the programming executive to determine if the contents of code memory and code-protect configuration bits (gcp and gwrp) are blank (contain all ? 1 ?s). the size of code memory to check must be specified in the command. the blank check for code memory begins at 0h and advances toward larger addresses for the specified number of instruction words. qblank returns a qe_code of f0h if the specified code memory and code-protect bits are blank; otherwise, qblank returns a qe_code of 0fh. expected response (2 words for blank device): 1af0h 0002h expected response (2 words for non-blank device): 1a0fh 0002h 15 12 11 8 7 0 opcode length data_msb addr_msb addr_ls data_ls field description opcode dh length 4h reserved 0h addr_msb msb of 24-bit destination address addr_ls least significant 16 bits of 24-bit destination address data_msb msb of 24-bit data data_ls least significant 16 bits of 24-bit data 15 12 11 0 opcode length psize_msw psize_lsw field description opcode ah length 3h psize length of program memory to check in 24-bit words plus one (max. of 49152) note: qblank does not check the system operation configuration bits, since these bits are not set to ? 1 ? when a chip erase is performed.
pic24fjxxxga0xx ds39768d-page 40 ? 2008 microchip technology inc. 5.2.12 qver command the qver command queries the version of the programming executive software stored in test memory. the ?version.revision? information is returned in the response?s qe_code using a single byte with the following format: main version in upper nibble and revision in the lower nibble (i.e., 23h means version 2.3 of programming executive software). expected response (2 words): 1bmnh (where ?mn? stands for version m.n) 0002h 5.3 programming executive responses the programming executive sends a response to the programmer for each command that it receives. the response indicates if the command was processed correctly. it includes any required response data or error data. the programming executive response set is shown in table 5-2. this table contains the opcode, mnemonic and description for each response. the response format is described in section 5.3.1 ?response format? . table 5-2: programming executive response op codes 5.3.1 response format all programming executive responses have a general format consisting of a two-word header and any required data for the command. 5.3.1.1 opcode field the opcode is a 4-bit field in the first word of the response. the opcode indicates how the command was processed (see table 5-2). if the command was processed successfully, the response opcode is pass. if there was an error in processing the command, the response opcode is fail and the qe_code indicates the reason for the failure. if the command sent to the programming executive is not identified, the programming executive returns a nack response. 5.3.1.2 last_cmd field the last_cmd is a 4-bit field in the first word of the response and indicates the command that the programming executive processed. since the program- ming executive can only process one command at a time, this field is technically not required. however, it can be used to verify that the programming executive correctly received the command that the programmer transmitted. 15 12 11 0 opcode length field description opcode bh length 1h opcode mnemonic description 1h pass command successfully processed 2h fail command unsuccessfully processed 3h nack command not known field description opcode response opcode last_cmd programmer command that generated the response qe_code query code or error code. length response length in 16-bit words (includes 2 header words) d_1 first 16-bit data word (if applicable) d_n last 16-bit data word (if applicable) 15 12 11 8 7 0 opcode last_cmd qe_code length d_1 (if applicable) ... d_n (if applicable)
? 2008 microchip technology inc. ds39768d-page 41 pic24fjxxxga0xx 5.3.1.3 qe_code field the qe_code is a byte in the first word of the response. this byte is used to return data for query commands and error codes for all other commands. when the programming executive processes one of the two query commands (q blank or qver), the returned opcode is always pass and the qe_code holds the query response data. the format of the qe_code for both queries is shown in table 5-3. table 5-3: qe_code for queries when the programming executive processes any command other than a query, the qe_code represents an error code. supported error codes are shown in table 5-4. if a command is successfully processed, the returned qe_code is set to 0h, which indicates that there was no error in the command processing. if the verify of the programming for the progp or progc command fails, the qe_code is set to 1h. for all other programming executive errors, the qe_code is 2h. table 5-4: qe_code for non-query commands 5.3.1.4 response length the response length indicates the length of the programming executive?s response in 16-bit words. this field includes the 2 words of the response header. with the exception of the response for the readp command, the length of each response is only 2 words. the response to the readp command uses the packed instruction word format described in section 5.2.2 ?packed data format? . when reading an odd number of program memory words (n odd), the response to the readp command is (3 * (n + 1)/2 + 2) words. when reading an even number of program memory words (n even), the response to the readp command is (3 * n/2 + 2) words. query qe_code qblank 0fh = code memory is not blank f0h = code memory is blank qver 0xmn, where programming executive software version = m.n (i.e., 32h means software version 3.2) qe_code description 0h no error 1h verify failed 2h other error
pic24fjxxxga0xx ds39768d-page 42 ? 2008 microchip technology inc. 5.4 programming the programming executive to memory 5.4.1 overview if it is determined that the programming executive is not present in executive memory (as described in section 4.2 ?confirming the presence of the programming executive? ), it must be programmed into executive memory using icsp, as described in section 3.0 ?device programming ? icsp? . storing the programming executive to executive memory is similar to normal programming of code memory. namely, the executive memory must be erased, and then the programming executive must be programmed 64 words at a time. erasing the last page of executive memory will cause the frc oscillator calibration settings and device diagnostic data in the diagnostic and calibration words, at addresses 8007f0h to 8007feh, to be erased. in order to retain this calibration, these memory locations should be read and stored prior to erasing executive memory. they should then be reprogrammed in the last words of pro- gram memory. this control flow is summarized in table 5-5. table 5-5: programming th e programming executive command (binary) data (hex) description step 1: exit reset vector and erase executive memory. 0000 0000 0000 000000 040200 000000 nop goto 0x200 nop step 2: initialize pointers to read diagnostic and calibration words for storage in w6-w13. 0000 0000 0000 0000 0000 200800 880190 207f00 2000c2 000000 mov #0x80, w0 mov w0, tblpag mov #0x07f0, w1 mov #0xc, w2 nop step 3: repeat this step 8 times to read diagnostic and calibration words, storing them in w registers, w6-w13. 0000 0000 0000 ba1931 000000 000000 tblrdl [w1++].[w2++] nop nop step 4: initialize the nvmcon to erase executive memory. 0000 0000 240420 883b00 mov #0x4042, w0 mov w0, nvmcon step 5: initialize erase pointers to first page of executive and then initiate the erase cycle. 0000 0000 0000 0000 0000 0000 0000 0000 00000 0000 200800 880190 200001 000000 bb0881 000000 000000 a8e761 000000 000000 mov #0x80, w0 mov w0, tblpag mov #0x0, w1 nop tblwtl w1, [w1] nop nop bset nvmcon, #15 nop nop step 6: repeat this step to poll the wr bit (bit 15 of nvmcon) until it is cleared by the hardware. 0000 0000 0000 0000 0001 0000 040200 000000 803b02 883c22 000000 000000 goto 0x200 nop mov nvmcon, w2 mov w2, visi nop clock out contents of the visi register. nop
? 2008 microchip technology inc. ds39768d-page 43 pic24fjxxxga0xx step 7: repeat steps 5 and 6 to erase the second page of executive memory. the w1 pointer should be incremented by 400h to point to the second page. step 8: initialize tblpag and nvmcon to write stored diagnostic and calibration as single words. initialize w1 and w2 as write and read pointers to rewrite stored diagnostic and calibration words. 0000 0000 0000 0000 0000 0000 0000 200800 880190 240031 883b01 207f00 2000c2 000000 mov #0x80, w0 mov w0, tblpag mov #0x4003, w1 mov w1, nvmcon mov #0x07f0, w1 mov #0xc, w2 nop step 9: perform write of a single word of calibration data and initiate single-word write cycle. 0000 0000 0000 0000 0000 0000 bb18b2 000000 000000 a8e761 000000 000000 tblwtl [w2++], [w1++] nop nop bset nvmcon, #15 nop nop step 10: repeat this step to poll the wr bit (bit 15 of nvmcon) until it is cleared by the hardware. 0000 0000 0000 0000 0000 0001 0000 040200 000000 803b00 883c20 000000 000000 goto 0x200 nop mov nvmcon, w0 mov w0, visi nop clock out contents of visi register. nop step 11: repeat steps 9-10 seven more times to program the remainder of the diagnostic and calibration words back into program memory. step 12: initialize the nvmcon to program 64 instruction words. 0000 0000 240010 883b00 mov #0x4001, w0 mov w0, nvmcon step 13: initialize tblpag and the write pointer (w7). 0000 0000 0000 0000 200800 880190 eb0380 000000 mov #0x80, w0 mov w0, tblpag clr w7 nop step 14: load w0:w5 with the next four words of packed programming executive code and initialize w6 for programming. programming starts from the base of executive memory (800000h) using w6 as a read pointer and w7 as a write pointer. 0000 0000 0000 0000 0000 0000 20 21 22 23 24 25 mov #, w0 mov #, w1 mov #, w2 mov #, w3 mov #, w4 mov #, w5 table 5-5: programming the programming executive (continued) command (binary) data (hex) description
pic24fjxxxga0xx ds39768d-page 44 ? 2008 microchip technology inc. step 15: set the read pointer (w6) and load the (next four write) latches. 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 eb0300 000000 bb0bb6 000000 000000 bbdbb6 000000 000000 bbebb6 000000 000000 bb1bb6 000000 000000 bb0bb6 000000 000000 bbdbb6 000000 000000 bbebb6 000000 000000 bb1bb6 000000 000000 clr w6 nop tblwtl [w6++], [w7] nop nop tblwth.b [w6++], [w7++] nop nop tblwth.b [w6++], [++w7] nop nop tblwtl [w6++], [w7++] nop nop tblwtl [w6++], [w7] nop nop tblwth.b [w6++], [w7++] nop nop tblwth.b [w6++], [++w7] nop nop tblwtl [w6++], [w7++] nop nop step 16: repeat steps 14-15, sixteen times, to load the write latches for the 64 instructions. step 17: initiate the programming cycle. 0000 0000 0000 a8e761 000000 000000 bset nvmcon, #15 nop nop step 18: repeat this step to poll the wr bit (bit 15 of nvmcon) until it is cleared by the hardware. 0000 0000 0000 0000 0000 0001 0000 040200 000000 803b02 883c22 000000 000000 goto 0x200 nop mov nvmcon, w2 mov w2, visi nop clock out contents of the visi register. nop step 19: reset the device internal pc. 0000 0000 040200 000000 goto 0x200 nop step 20: repeat steps 14-19 until all 16 rows of executive memory have been programmed. on the final row, make sure to initialize the write latches at the diagnostic and calibration words locations with 0xffffff to ensure that the calibration is not overwritten. table 5-5: programming the programming executive (continued) command (binary) data (hex) description
? 2008 microchip technology inc. ds39768d-page 45 pic24fjxxxga0xx 5.4.2 programming verification after the programming executive has been programmed to executive memory using icsp, it must be verified. verification is performed by reading out the contents of executive memory and comparing it with the image of the programming executive stored in the programmer. reading the contents of executive memory can be performed using the same technique described in section 3.8 ?reading code memory? . a procedure for reading executive memory is shown in table 5-6. note that in step 2, the tblpag register is set to 80h, such that executive memory may be read. the last eight words of executive memory should be verified with stored values of the diagnostic and calibration words to ensure accuracy. table 5-6: reading executive memory command (binary) data (hex) description step 1: exit the reset vector. 0000 0000 0000 000000 040200 000000 nop goto 0x200 nop step 2: initialize tblpag and the read pointer (w6) for tblrd instruction. 0000 0000 0000 200800 880190 eb0300 mov #0x80, w0 mov w0, tblpag clr w6 step 3: initialize the write pointer (w7) to point to the visi register. 0000 0000 207847 000000 mov #visi, w7 nop step 4: read and clock out the contents of the next two locations of executive memory through the visi register using the regout command. 0000 0000 0000 0001 0000 0000 0000 0000 0000 0000 0000 0001 0000 0000 0000 0000 0001 0000 ba0b96 000000 000000 000000 badbb6 000000 000000 bad3d6 000000 000000 000000 ba0bb6 000000 000000 000000 tblrdl [w6], [w7] nop nop clock out contents of visi register nop tblrdh.b [w6++], [w7++] nop nop tblrdh.b [++w6], [w7--] nop nop clock out contents of visi register nop tblrdl [w6++], [w7] nop nop clock out contents of visi register nop step 5: reset the device internal pc. 0000 0000 040200 000000 goto 0x200 nop step 6: repeat steps 4 and 5 until all desired code memory is read.
pic24fjxxxga0xx ds39768d-page 46 ? 2008 microchip technology inc. 6.0 device details 6.1 device id the device id region of memory can be used to determine mask, variant and manufacturing information about the chip. the device id region is 2 x 16 bits and it can be read using the readc command. this region of memory is read-only and can also be read when code protection is enabled. table 6-1 shows the device id for each device, table 6-2 shows the device id registers and table 6-3 describes the bit field of each register. table 6-2: pic24fjxxxga0xx device id registers table 6-3: device id bit descriptions table 6-1: device ids device devid pic24fj16ga002 0444h pic24fj16ga004 044ch pic24fj32ga002 0445h pic24fj32ga004 044dh pic24fj48ga002 0446h pic24fj48ga004 044eh pic24fj64ga002 0447h pic24fj64ga004 044fh pic24fj64ga006 0405h pic24fj64ga008 0408h pic24fj64ga010 040bh pic24fj96ga006 0406h pic24fj96ga008 0409h pic24fj96ga010 040ch pic24fj128gaga006 0407h pic24fj128gaga008 040ah pic24fj128gaga010 040dh address name bit 1514131211109876543210 ff0000h devid ? famid<7:0> dev<5:0> ff0002h devrev ?majrv<2:0> ?dot<2:0> bit field register description famid<7:0> devid encodes the family id of the device dev<5:0> devid encodes the individual id of the device majrv<2:0> devrev encodes the major revision number of the device dot<2:0> devrev encodes the minor revision number of the device
? 2008 microchip technology inc. ds39768d-page 47 pic24fjxxxga0xx 6.2 checksum computation checksums for the pic24fjxxxga0xx family are 16 bits in size. the checksum is calculated by summing the following: ? contents of code memory locations ? contents of configuration registers table 6-4 describes how to calculate the checksum for each device. all memory locations are summed, one byte at a time, using only their native data size. more specifically, configuration registers are summed by adding the lower two bytes of these locations (the upper byte is ignored), while code memory is summed by adding all three bytes of code memory. table 6-4: checksum computation device read code protection checksum computation erased checksum value checksum with 0xaaaaaa at 0x0 and last code address pic24fj16ga002 disabled cfgb + sum(0:02bfb) 0xbb5a 0xb95c enabled 0 0x0000 0x0000 pic24fj16ga004 disabled cfgb + sum(0:02bfb) 0xbb5a 0xb95c enabled 0 0x0000 0x0000 pic24fj32ga002 disabled cfgb + sum(0:057fb) 0x795a 0x775c enabled 0 0x0000 0x0000 pic24fj32ga004 disabled cfgb + sum(0:057fb) 0x795a 0x775c enabled 0 0x0000 0x0000 pic24fj48ga002 disabled cfgb + sum(0:083fb) 0x375a 0x355c enabled 0 0x0000 0x0000 pic24fj48ga004 disabled cfgb + sum(0:083fb) 0x375a 0x355c enabled 0 0x0000 0x0000 pic24fj64ga002 disabled cfgb + sum(0:0abfb) 0xfb5a 0xf95c enabled 0 0x0000 0x0000 pic24fj64ga004 disabled cfgb + sum(0:0abfb) 0xfb5a 0xf95c enabled 0 0x0000 0x0000 pic24fj64ga006 disabled cfgb + sum(0:0abfb) 0xfacc 0xf8ce enabled 0 0x0000 0x0000 pic24fj64ga008 disabled cfgb + sum(0:0abfb) 0xfacc 0xf8ce enabled 0 0x0000 0x0000 pic24fj64ga010 disabled cfgb + sum(0:0abfb) 0xfacc 0xf8ce enabled 0 0x0000 0x0000 pic24fj96ga006 disabled cfgb + sum(0:0fffb) 0x7ccc 0x7ace enabled 0 0x0000 0x0000 pic24fj96ga008 disabled cfgb + sum(0:0fffb) 0x7ccc 0x7ace enabled 0 0x0000 0x0000 pic24fj96ga010 disabled cfgb + sum(0:0fffb) 0x7ccc 0x7ace enabled 0 0x0000 0x0000 legend: item description sum[a:b] = byte sum of locations, a to b inclusive (all 3 bytes of code memory) cfgb = configuration block (masked), 64/80/100-pin devices = byte sum of (cw1 & 0x7ddf + cw2 & 0x87e3) 28/44-pin devices = byte sum of (cw1 & 0x7fdf + cw2 & 0xfff7) note: cw1 address is last location of implemented program memory; cw2 is (last location ? 2).
pic24fjxxxga0xx ds39768d-page 48 ? 2008 microchip technology inc. pic24fj128gaga006 disabled cfgb + sum(0:0157fb) 0xf8cc 0xf6ce enabled 0 0x0000 0x0000 pic24fj128gaga008 disabled cfgb + sum(0:0157fb) 0xf8cc 0xf6ce enabled 0 0x0000 0x0000 pic24fj128gaga010 disabled cfgb + sum(0:0157fb) 0xf8cc 0xf6ce enabled 0 0x0000 0x0000 table 6-4: checksum computation (continued) device read code protection checksum computation erased checksum value checksum with 0xaaaaaa at 0x0 and last code address legend: item description sum[a:b] = byte sum of locations, a to b inclusive (all 3 bytes of code memory) cfgb = configuration block (masked), 64/80/100-pin devices = byte sum of (cw1 & 0x7ddf + cw2 & 0x87e3) 28/44-pin devices = byte sum of (cw1 & 0x7fdf + cw2 & 0xfff7) note: cw1 address is last location of implemented program memory; cw2 is (last location ? 2).
? 2008 microchip technology inc. ds39768d-page 49 pic24fjxxxga0xx 7.0 ac/dc characteristics and timing requirements standard operating conditions operating temperature: 0 c to +70 c. programming at +25 c is recommended. param no. symbol characteristic min max units conditions d111 v dd supply voltage during programming v ddcore + 0.1 3.60 v normal programming (1,2) d112 i pp programming current on mclr ?5 a d113 i ddp supply current during programming ? 2 ma d031 v il input low voltage v ss 0.2 v dd v d041 v ih input high voltage 0.8 v dd v dd v d080 v ol output low voltage ? 0.4 v i ol = 8.5 ma @ 3.6v d090 v oh output high voltage 3.0 ? v i oh = -3.0 ma @ 3.6v d012 c io capacitive loading on i/o pin (pgdx) ? 50 pf to meet ac specifications d013 c f filter capacitor value on v cap 4.7 10 f required for controller core p1 t pgc serial clock (pgcx) period 100 ? ns p1a t pgcl serial clock (pgcx) low time 40 ? ns p1b t pgch serial clock (pgcx) high time 40 ? ns p2 t set 1 input data setup time to serial clock 15 ? ns p3 t hld 1 input data hold time from pgcx 15 ? ns p4 t dly 1 delay between 4-bit command and command operand 40 ? ns p4a t dly 1 a delay between 4-bit command operand and next 4-bit command 40 ? ns p5 t dly 2 delay between last pgcx of command byte to first pgcx of read of data word 20 ? ns p6 t set 2v dd setup time to mclr 100 ? ns p7 t hld 2 input data hold time from mclr 25 ? ms p8 t dly 3 delay between last pgcx of command byte to pgdx by programming executive 12 ? s p9 t dly 4 programming executive command processing time 40 ? s p10 t dly 6 pgcx low time after programming 400 ? ns p11 t dly 7 chip erase time 400 ? ms p12 t dly 8 page erase time 40 ? ms p13 t dly 9 row programming time 2 ? ms p14 t r mclr rise time to enter icsp? mode ? 1.0 s p15 t valid data out valid from pgcx 10 ? ns p16 t dly 10 delay between last pgcx and mclr 0?s p17 t hld 3mclr to v dd 100 ? ns p18 t key 1 delay from first mclr to first pgcx for key sequence on pgdx 40 ? ns p19 t key 2 delay from last pgcx for key sequence on pgdx to second mclr 1?ms p20 t dly 11 delay between pgdx by programming executive to pgdx driven by host 23 ? s p21 t dly 12 delay between programming executive command response words 8?ns note 1: v ddcore must be supplied to the v ddcore /v cap pin if the on-chip voltage regulator is disabled. see section 2.1 ?power requirements? for more information. (minimum v ddcore allowing flash programming is 2.25v.) 2: v dd must also be supplied to the av dd pins during programming. av dd and av ss should always be within 0.3v of v dd and v ss , respectively.
pic24fjxxxga0xx ds39768d-page 50 ? 2008 microchip technology inc. notes:
? 2008 microchip technology inc. ds39768d-page 51 information contained in this publication regarding device applications and the like is provided only for your convenience and may be superseded by updates. it is your responsibility to ensure that your application meets with your specifications. microchip makes no representations or warranties of any kind whether express or implied, written or oral, statutory or otherwise, related to the information, including but not limited to its condition, quality, performance, merchantability or fitness for purpose . microchip disclaims all liability arising from this information and its use. use of microchip devices in life support and/or safety applications is entirely at the buyer?s risk, and the buyer agrees to defend, indemnify and hold harmless microchip from any and all damages, claims, suits, or expenses resulting from such use. no licenses are conveyed, implicitly or otherwise, under any microchip intellectual property rights. trademarks the microchip name and logo, the microchip logo, accuron, dspic, k ee l oq , k ee l oq logo, mplab, pic, picmicro, picstart, rfpic, smartshunt and uni/o are registered trademarks of microchip tec hnology incorporated in the u.s.a. and other countries. filterlab, linear active thermistor, mxdev, mxlab, seeval, smartsensor and the embedded control solutions company are registered trademarks of microchip technology incorporated in the u.s.a. analog-for-the-digital age, appl ication maestro, codeguard, dspicdem, dspicdem.net, dspicworks, dsspeak, ecan, economonitor, fansense, in-circuit serial programming, icsp, icepic, mindi, miwi, mpasm, mplab certified logo, mplib, mplink, mtouch, pickit, picdem, picdem.net, pictail, pic 32 logo, powercal, powerinfo, powermate, powertool, real ice, rflab, select mode, total endurance, wiperlock and zena are trademarks of microchip technology incorporated in the u.s.a. and other countries. sqtp is a service mark of microchip technology incorporated in the u.s.a. all other trademarks mentioned herein are property of their respective companies. ? 2008, microchip technology incorporated, printed in the u.s.a., all rights reserved. printed on recycled paper. note the following details of the code protection feature on microchip devices: ? microchip products meet the specification cont ained in their particular microchip data sheet. ? microchip believes that its family of products is one of the most secure families of its kind on the market today, when used i n the intended manner and under normal conditions. ? there are dishonest and possibly illegal methods used to breach the code protection feature. all of these methods, to our knowledge, require using the microchip products in a manner outside the operating specif ications contained in microchip?s data sheets. most likely, the person doing so is engaged in theft of intellectual property. ? microchip is willing to work with the customer who is concerned about the integrity of their code. ? neither microchip nor any other semiconduc tor manufacturer can guarantee the security of their code. code protection does not mean that we are guaranteeing the product as ?unbreakable.? code protection is constantly evolving. we at microchip are co mmitted to continuously improvin g the code protection features of our products. attempts to break microchip?s code protection feature may be a violation of the digital millennium copyright act. if such acts allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that act. microchip received iso/ts-16949:2002 certification for its worldwide headquarters, design and wafer fabrication facilities in chandler and tempe, arizona; gresham, oregon and design centers in california and india. the company?s quality system processes and procedures are for its pic ? mcus and dspic ? dscs, k ee l oq ? code hopping devices, serial eeproms, microperipherals, nonvolatile memory and analog products. in addition, microchip?s quality system for the design and manufacture of development systems is iso 9001:2000 certified.
ds39768c-page 52 ? 2008 microchip technology inc. americas corporate office 2355 west chandler blvd. chandler, az 85224-6199 tel: 480-792-7200 fax: 480-792-7277 technical support: http://support.microchip.com web address: www.microchip.com atlanta duluth, ga tel: 678-957-9614 fax: 678-957-1455 boston westborough, ma tel: 774-760-0087 fax: 774-760-0088 chicago itasca, il tel: 630-285-0071 fax: 630-285-0075 dallas addison, tx tel: 972-818-7423 fax: 972-818-2924 detroit farmington hills, mi tel: 248-538-2250 fax: 248-538-2260 kokomo kokomo, in tel: 765-864-8360 fax: 765-864-8387 los angeles mission viejo, ca tel: 949-462-9523 fax: 949-462-9608 santa clara santa clara, ca tel: 408-961-6444 fax: 408-961-6445 toronto mississauga, ontario, canada tel: 905-673-0699 fax: 905-673-6509 asia/pacific asia pacific office suites 3707-14, 37th floor tower 6, the gateway harbour city, kowloon hong kong tel: 852-2401-1200 fax: 852-2401-3431 australia - sydney tel: 61-2-9868-6733 fax: 61-2-9868-6755 china - beijing tel: 86-10-8528-2100 fax: 86-10-8528-2104 china - chengdu tel: 86-28-8665-5511 fax: 86-28-8665-7889 china - hong kong sar tel: 852-2401-1200 fax: 852-2401-3431 china - nanjing tel: 86-25-8473-2460 fax: 86-25-8473-2470 china - qingdao tel: 86-532-8502-7355 fax: 86-532-8502-7205 china - shanghai tel: 86-21-5407-5533 fax: 86-21-5407-5066 china - shenyang tel: 86-24-2334-2829 fax: 86-24-2334-2393 china - shenzhen tel: 86-755-8203-2660 fax: 86-755-8203-1760 china - wuhan tel: 86-27-5980-5300 fax: 86-27-5980-5118 china - xiamen tel: 86-592-2388138 fax: 86-592-2388130 china - xian tel: 86-29-8833-7252 fax: 86-29-8833-7256 china - zhuhai tel: 86-756-3210040 fax: 86-756-3210049 asia/pacific india - bangalore tel: 91-80-4182-8400 fax: 91-80-4182-8422 india - new delhi tel: 91-11-4160-8631 fax: 91-11-4160-8632 india - pune tel: 91-20-2566-1512 fax: 91-20-2566-1513 japan - yokohama tel: 81-45-471- 6166 fax: 81-45-471-6122 korea - daegu tel: 82-53-744-4301 fax: 82-53-744-4302 korea - seoul tel: 82-2-554-7200 fax: 82-2-558-5932 or 82-2-558-5934 malaysia - kuala lumpur tel: 60-3-6201-9857 fax: 60-3-6201-9859 malaysia - penang tel: 60-4-227-8870 fax: 60-4-227-4068 philippines - manila tel: 63-2-634-9065 fax: 63-2-634-9069 singapore tel: 65-6334-8870 fax: 65-6334-8850 taiwan - hsin chu tel: 886-3-572-9526 fax: 886-3-572-6459 taiwan - kaohsiung tel: 886-7-536-4818 fax: 886-7-536-4803 taiwan - taipei tel: 886-2-2500-6610 fax: 886-2-2508-0102 thailand - bangkok tel: 66-2-694-1351 fax: 66-2-694-1350 europe austria - wels tel: 43-7242-2244-39 fax: 43-7242-2244-393 denmark - copenhagen tel: 45-4450-2828 fax: 45-4485-2829 france - paris tel: 33-1-69-53-63-20 fax: 33-1-69-30-90-79 germany - munich tel: 49-89-627-144-0 fax: 49-89-627-144-44 italy - milan tel: 39-0331-742611 fax: 39-0331-466781 netherlands - drunen tel: 31-416-690399 fax: 31-416-690340 spain - madrid tel: 34-91-708-08-90 fax: 34-91-708-08-91 uk - wokingham tel: 44-118-921-5869 fax: 44-118-921-5820 w orldwide s ales and s ervice 01/02/08


▲Up To Search▲   

 
Price & Availability of PIC24FJ16GA004-EPT

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X